package com.ruoyi.manager.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manager.domain.SoldierArrangeInfo;
import com.ruoyi.manager.service.ISoldierArrangeInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 退役军人_安置信息Controller
 *
 * @author Allen
 * @date 2021-08-30
 */
@RestController
@RequestMapping("/manager/retirefm_2")
public class SoldierArrangeInfoController extends BaseController {
    @Autowired
    private ISoldierArrangeInfoService soldierArrangeInfoService;

    /**
     * 查询退役军人_安置信息列表
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_2:list')")
    @GetMapping("/list")
    public TableDataInfo list(SoldierArrangeInfo soldierArrangeInfo) {
        startPage();
        List<SoldierArrangeInfo> list = soldierArrangeInfoService.selectSoldierArrangeInfoList(soldierArrangeInfo);
        return getDataTable(list);
    }

    /**
     * 导出退役军人_安置信息列表
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_2:export')")
    @Log(title = "退役军人_安置信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SoldierArrangeInfo soldierArrangeInfo) {
        List<SoldierArrangeInfo> list = soldierArrangeInfoService.selectSoldierArrangeInfoList(soldierArrangeInfo);
        ExcelUtil<SoldierArrangeInfo> util = new ExcelUtil<SoldierArrangeInfo>(SoldierArrangeInfo.class);
        return util.exportExcel(list, "退役军人_安置信息数据");
    }

    /**
     * 获取退役军人_安置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_2:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(soldierArrangeInfoService.selectSoldierArrangeInfoById(id));
    }

    /**
     * 新增退役军人_安置信息
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_2:add')")
    @Log(title = "退役军人_安置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SoldierArrangeInfo soldierArrangeInfo) {
        return toAjax(soldierArrangeInfoService.insertSoldierArrangeInfo(soldierArrangeInfo));
    }

    /**
     * 修改退役军人_安置信息
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_2:edit')")
    @Log(title = "退役军人_安置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SoldierArrangeInfo soldierArrangeInfo) {
        return toAjax(soldierArrangeInfoService.updateSoldierArrangeInfo(soldierArrangeInfo));
    }

    /**
     * 删除退役军人_安置信息
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_2:remove')")
    @Log(title = "退役军人_安置信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(soldierArrangeInfoService.deleteSoldierArrangeInfoByIds(ids));
    }
}
